﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using e1;

namespace F1_OrderController
{
    
    public partial class Form3 : Form
    {

        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (button1.Text == "添加")
                {
                    Orders.orderService.AddOrder(new Order(new OrderDetails(Convert.ToInt32(idBox.Text), goodsBox.Text, Convert.ToDouble(priceBox.Text), customerBox.Text)));
                }
                else if (button1.Text == "删除")
                {
                    Orders.orderService.DelOrder(new Order(new OrderDetails(Convert.ToInt32(idBox.Text), goodsBox.Text, Convert.ToDouble(priceBox.Text), customerBox.Text)));
                }
            }
            catch(Exception exception)
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult dr = MessageBox.Show(exception.Message, "提示", messButton);
            }
            this.Close();
        }

        public void changeTitle(String title,String buttonName)
        {
            titleLabel.Text = title;
            button1.Text = buttonName;
        }
    }
}
